<template>
  <div class="container">
    <!-- 酒店基本信息 -->
    <div class="message">
      <el-row>
        <el-col :span="24">
          <div class="nav" v-if="hotelData.city">
            酒店>{{ hotelData.real_city }}酒店>{{ hotelData.name }}
          </div>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <div class="hotelname">{{ hotelData.name }}</div>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <div class="hotelnamePinyin">
            {{ hotelData.alias }}
          </div>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <div class="address">
            <i class="el-icon-location"></i> {{ hotelData.address }}
          </div>
        </el-col>
      </el-row>
    </div>

    <!-- 图片 -->
    <div class="images">
      <el-row>
        <el-col :span="16">
          <div class="left">
            <img :src="baseSrc" alt="" class="main" />
          </div>
        </el-col>
        <el-col :span="8">
          <div class="right">
            <img
              :src="item.address"
              alt=""
              class="small"
              v-for="(item, index) in imgData"
              :key="index"
              @click="handleimg(index)"
            />
          </div>
        </el-col>
      </el-row>
    </div>

    <el-tabs v-model="activeName" @tab-click="handleClick" :stretch="true">
      <el-tab-pane label="酒店价格" name="first">
        <DetailedPrice :products="hotelData.products" />
      </el-tab-pane>
      <el-tab-pane label="酒店周边" name="second">
        <DetailedMap :location="hotelData.location" />
      </el-tab-pane>
      <el-tab-pane label="酒店配置" name="third">
        <DetaileMessage :hotelData="hotelData" />
      </el-tab-pane>
      <el-tab-pane label="酒店评价" name="fourth">
        <DetailedComment :hotelData="hotelData" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeName: "first", //tab栏切换显示的第一个栏目
      baseSrc: require("~/assets/images/1.jpeg"),
      imgData: [
        {
          address: require("~/assets/images/1.jpeg"),
        },
        {
          address: require("~/assets/images/2.jpeg"),
        },
        {
          address: require("~/assets/images/3.jpeg"),
        },
        {
          address: require("~/assets/images/4.jpeg"),
        },
        {
          address: require("~/assets/images/5.jpeg"),
        },
        {
          address: require("~/assets/images/6.jpeg"),
        },
      ],

      hotelData: {},
    };
  },

  created() {
    this.$axios({
      url: "/hotels?id=" + this.$route.query.id,
    }).then((res) => {
      // console.log(res.data);
      this.hotelData = res.data.data[0];
      // console.log(this.hotelData);
    });
  },

  methods: {
    handleimg(index) {
      this.baseSrc = this.imgData[index].address;
    },
    handleClick(tab, event) {
      // console.log(tab, event);
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  width: 1000px;
  margin: 20px auto;
  // 面包屑
  .nav {
    font-size: 14px;
    margin-bottom: 20px;
  }
  // 基本酒店信息
  .hotelname {
    font-size: 24px;
    font-weight: 700;
  }

  .hotelnamePinyin {
    font-size: 16px;
  }

  .address {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .images {
    height: 360px;
    // background-color: red;
    margin-bottom: 20px;
    .main {
      width: 640px;
      height: 360px;
      display: block;
    }

    .right {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;

      .small {
        width: 160px;
        height: 112px;
        cursor: pointer;
        &:nth-child(3),
        &:nth-child(4) {
          margin: 12px 0;
        }
      }
    }
  }

  /deep/.el-tabs__header .is-top {
    font-size: 18px;
    font-weight: 700;
  }
}
</style>